import 'package:flutter/material.dart';

class MyHeader extends StatelessWidget {
  Widget _notLoginBudilder(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.green,
      ),
      height: 95,
      child: Row(
        children: <Widget>[
          Container(
              height: 65,
              width: 65,
              margin: EdgeInsets.only(right: 15, left: 15),
              child: CircleAvatar(
                backgroundImage: NetworkImage(
                    "https://tva1.sinaimg.cn/large/006y8mN6ly1g6tbgbqv2nj30i20i2wen.jpg"),
              )),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Padding(padding: EdgeInsets.all(13)),
              GestureDetector(
                onTap: () {
                  Navigator.of(context).pushNamed("login");
                },
                child: Text(
                  "登录/注册",
                  style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w600,
                      color: Colors.white),
                ),
              ),
              Text(
                "登陆后可以体验更多",
                style: TextStyle(color: Colors.white),
              )
            ],
          )
        ],
      ),
    );
  }

  Widget _loginBudilder(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.green,
      ),
      height: 95,
      child: Row(
        children: <Widget>[
          Container(
              height: 65,
              width: 65,
              margin: EdgeInsets.only(right: 15, left: 15),
              child: CircleAvatar(
                backgroundImage: NetworkImage(
                    "https://tva1.sinaimg.cn/large/006y8mN6ly1g6tbnovh8jj30hr0hrq3l.jpg"),
              )),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Padding(padding: EdgeInsets.all(13)),
              GestureDetector(
                onTap: () {
                  Navigator.of(context).pushNamed("login");
                },
                child: Text(
                  "小伙子",
                  style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w600,
                      color: Colors.white),
                ),
              ),
              Text(
                "查看编辑个人资料",
                style: TextStyle(color: Colors.white),
              )
            ],
          )
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    var isLogin = false;
    return isLogin ? _notLoginBudilder(context) : _loginBudilder(context);
  }
}
